export default {
    namespaced: true,
    state: {
        newestMessage: {type: ""},
        historyMessage: []
    },
    mutations: {
        messageOperate(state, option) {
            if (Object.prototype.toString.call(option) === "[object Array]") {
                if (option.length > 0) {
                    switch (String(option[0]).toLowerCase()) {
                        case "updatemessage":
                            if (Object.prototype.toString.call(option[1]) === "[object Object]") {
                                state.newestMessage = option[1];
                                state.historyMessage.push(option[1]);
                            }
                            break;
                        case"overwritehistorymessage":
                            if (Object.prototype.toString.call(option[1]) === "[object Array]") {
                                state.historyMessage.splice(0);
                                state.historyMessage.push(...option[1]);
                            }
                            break;
                    }
                }
            }
        }
    }
}